package xm.control.bar.base
{
	import flash.display.Stage;
	
	import xm.core.XMSprite;
	
	/**
	 * <br> 클래스 설명 : </br>
	 * @author 김정환
	 */	
	public class BarBase extends XMSprite
	{
		
		//-----------------------------------------------------------------------------------
		// public vars
		//-----------------------------------------------------------------------------------
		
		/**
		 * stage 의 어디에 붙을지 결정. ( default : top ) , bottom 두가지만 있음. 
		 */		
		public var align : String = "top";
		
		//-----------------------------------------------------------------------------------
		// protected / internal vars
		//-----------------------------------------------------------------------------------
		
		/**
		 * Stage
		 */		
		protected var s : Stage;
		
		/**
		 * 컨텐츠 유무 결정. 
		 */		
		protected var isContent : Boolean = true;
		
		//-----------------------------------------------------------------------------------
		// private vars
		//-----------------------------------------------------------------------------------
		
		
		
		//-----------------------------------------------------------------------------------
		// public functions
		//-----------------------------------------------------------------------------------
		
		/**
		 * constructor 
		 */	
		public function BarBase()
		{
			super();
		}
		
		
		/**
		 * 스테이지 셋팅
		 * @param stage
		 */		
		public function setStage( stage:Stage ):void
		{
			this.s = stage;
			this.s.addChildAt( this, 1 );
			
			updateDisplayList();
		}
		
		/**
		 *  updateDisplayList
		 */		
		override public function updateDisplayList( enforce : Boolean = false ):void
		{
			if( s )
			{
				this.viewWidth = s.stageWidth;
			}
			
			super.updateDisplayList( enforce );
		}

		//-----------------------------------------------------------------------------------
		// LifeCycle functions
		//-----------------------------------------------------------------------------------
		
		
		/**
		 * </ br>
		 * createChildren
		 */		
		override public function createChildren():void
		{
			super.createChildren();
			
			this.backgroundAlpha = 1;
			this.backgroundColor = 0x000000;
		}
		
		
		/**
		 * createComplete
		 */		
		override public function creationComplete():void
		{
			super.creationComplete();
		}
		
		
		/**
		 * add
		 */		
		override public function add():void
		{
			super.add();
		}
		
		
		/**
		 * remove
		 */		
		override public function remove():void
		{
			super.remove();
			
		}
		
		/**
		 * destroy
		 */		
		override public function destroy():void
		{
			
			align = null;
			s = null;
			isContent = false;
			
			super.destroy();
		}
		
		
		
		
		/**
		 * stage에 해당 바를 붙임. 
		 */		
		public function addToStage():void
		{
			if( this.s.contains( this ) == false )
			{
				s.addChild( this );
			}
		}
		
		/**
		 * stage에서 해당 바를 제거함. 
		 */		
		public function removeFromStage():void
		{
			if( s.contains( this ) )
			{
				s.removeChild( this );
			}
		}
		
		
		
		

		//-----------------------------------------------------------------------------------
		// setter / getter
		//-----------------------------------------------------------------------------------
		
		
		//-----------------------------------------------------------------------------------
		// protected functions
		//-----------------------------------------------------------------------------------
		
		
		
		//-----------------------------------------------------------------------------------
		// internal functions
		//-----------------------------------------------------------------------------------
		
		
		
		
		//-----------------------------------------------------------------------------------
		// private functions
		//-----------------------------------------------------------------------------------
		
		
		
		//-----------------------------------------------------------------------------------
		// event handler
		//-----------------------------------------------------------------------------------
		
		
		
		
		
		
		
		
		
		
		
		
	}
}